import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Bool;
import org.fisco.bcos.sdk.abi.datatypes.DynamicArray;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple3;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple4;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple8;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class Shipment extends Contract {
    public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b506116f1806100206000396000f3006080604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305e583c6146100a9578063079eaf341461012b578063092b3740146101da5780633e92ecab1461037b57806346fe46f9146104705780635c622a0e146104fb5780635df2d368146105a15780635f22ba3b14610664578063986f0e4c146106d7578063c64cb4ed146107f0575b600080fd5b3480156100b557600080fd5b506100d46004803603810190808035906020019092919050505061087b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101175780820151818401526020810190506100fc565b505050509050019250505060405180910390f35b34801561013757600080fd5b506101d8600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506108f5565b005b3480156101e657600080fd5b506102056004803603810190808035906020019092919050505061099d565b60405180898152602001888152602001878152602001806020018060200180602001868152602001858152602001848103845289818151815260200191508051906020019080838360005b8381101561026b578082015181840152602081019050610250565b50505050905090810190601f1680156102985780820380516001836020036101000a031916815260200191505b50848103835288818151815260200191508051906020019080838360005b838110156102d15780820151818401526020810190506102b6565b50505050905090810190601f1680156102fe5780820380516001836020036101000a031916815260200191505b50848103825287818151815260200191508051906020019080838360005b8381101561033757808201518184015260208101905061031c565b50505050905090810190601f1680156103645780820380516001836020036101000a031916815260200191505b509b50505050505050505050505060405180910390f35b34801561038757600080fd5b5061046e600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610c46565b005b34801561047c57600080fd5b506104e160048036038101908080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610d86565b604051808215151515815260200191505060405180910390f35b34801561050757600080fd5b5061052660048036038101908080359060200190929190505050610e98565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561056657808201518184015260208101905061054b565b50505050905090810190601f1680156105935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156105ad57600080fd5b506106626004803603810190808035906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610f5d565b005b34801561067057600080fd5b506106d560048036038101908080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506110a0565b005b3480156106e357600080fd5b5061070260048036038101908080359060200190929190505050611104565b604051808481526020018060200180602001838103835285818151815260200191508051906020019080838360005b8381101561074c578082015181840152602081019050610731565b50505050905090810190601f1680156107795780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b838110156107b2578082015181840152602081019050610797565b50505050905090810190601f1680156107df5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b3480156107fc57600080fd5b5061086160048036038101908080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506113a9565b604051808215151515815260200191505060405180910390f35b6060600180830381548110151561088e57fe5b90600052602060002090600502016004018054806020026020016040519081016040528092919081815260200182805480156108e957602002820191906000526020600020905b8154815260200190600101908083116108d5575b50505050509050919050565b6108fd6114bb565b6060604051908101604052806001600080549050018152602001848152602001838152509050600081908060018154018082558091505090600182039060005260206000209060030201600090919290919091506000820151816000015560208201518160010190805190602001906109779291906114dd565b5060408201518160020190805190602001906109949291906114dd565b50505050505050565b600080600060608060606000806109b261155d565b600260018b038154811015156109c457fe5b90600052602060002090600802016101006040519081016040529081600082015481526020016001820154815260200160028201548152602001600382018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a965780601f10610a6b57610100808354040283529160200191610a96565b820191906000526020600020905b815481529060010190602001808311610a7957829003601f168201915b50505050508152602001600482018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b385780601f10610b0d57610100808354040283529160200191610b38565b820191906000526020600020905b815481529060010190602001808311610b1b57829003601f168201915b50505050508152602001600582018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610bda5780601f10610baf57610100808354040283529160200191610bda565b820191906000526020600020905b815481529060010190602001808311610bbd57829003601f168201915b50505050508152602001600682015481526020016007820154815250509050806000015181602001518260400151836060015184608001518560a001518660c001518760e001518494508393508292509850985098509850985098509850985050919395975091939597565b6000610c506115a3565b60a0604051908101604052806001808054905001815260200186815260200185815260200184815260200183805480602002602001604051908101604052809291908181526020018280548015610cc657602002820191906000526020600020905b815481526020019060010190808311610cb2575b5050505050815250905060018190806001815401808255809150509060018203906000526020600020906005020160009091929091909150600082015181600001556020820151816001019080519060200190610d249291906114dd565b506040820151816002019080519060200190610d419291906114dd565b506060820151816003019080519060200190610d5e9291906114dd565b506080820151816004019080519060200190610d7b9291906115d3565b505050505050505050565b6000816040518082805190602001908083835b602083101515610dbe5780518252602082019150602081019050602083039250610d99565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916600060018503815481101515610e0157fe5b90600052602060002090600302016002016040518082805460018160011615610100020316600290048015610e6d5780601f10610e4b576101008083540402835291820191610e6d565b820191906000526020600020905b815481529060010190602001808311610e59575b50509150506040518091039020600019161415610e8d5760019050610e92565b600090505b92915050565b6060600260018303815481101515610eac57fe5b90600052602060002090600802016005018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f515780601f10610f2657610100808354040283529160200191610f51565b820191906000526020600020905b815481529060010190602001808311610f3457829003601f168201915b50505050509050919050565b610f6561155d565b6101006040519081016040528060016002805490500181526020018681526020018581526020018481526020018381526020016040805190810160405280600981526020017fe5be85e68fbde694b600000000000000000000000000000000000000000000008152508152602001428152602001428152509050","6002819080600181540180825580915050906001820390600052602060002090600802016000909192909190915060008201518160000155602082015181600101556040820151816002015560608201518160030190805190602001906110479291906114dd565b5060808201518160040190805190602001906110649291906114dd565b5060a08201518160050190805190602001906110819291906114dd565b5060c0820151816006015560e082015181600701555050505050505050565b806002600184038154811015156110b357fe5b906000526020600020906008020160050190805190602001906110d7929190611620565b50426002600184038154811015156110eb57fe5b9060005260206000209060080201600701819055505050565b60006060806111116115a3565b600180860381548110151561112257fe5b906000526020600020906005020160a0604051908101604052908160008201548152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111df5780601f106111b4576101008083540402835291602001916111df565b820191906000526020600020905b8154815290600101906020018083116111c257829003601f168201915b50505050508152602001600282018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112815780601f1061125657610100808354040283529160200191611281565b820191906000526020600020905b81548152906001019060200180831161126457829003601f168201915b50505050508152602001600382018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081526020016004820180548060200260200160405190810160405280929190818152602001828054801561137b57602002820191906000526020600020905b815481526020019060010190808311611367575b5050505050815250509050806000015181602001518260400151819150809050935093509350509193909250565b6000816040518082805190602001908083835b6020831015156113e157805182526020820191506020810190506020830392506113bc565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660006001850381548110151561142457fe5b906000526020600020906003020160020160405180828054600181600116156101000203166002900480156114905780601f1061146e576101008083540402835291820191611490565b820191906000526020600020905b81548152906001019060200180831161147c575b505091505060405180910390206000191614156114b057600190506114b5565b600090505b92915050565b6060604051908101604052806000815260200160608152602001606081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061151e57805160ff191683800117855561154c565b8280016001018555821561154c579182015b8281111561154b578251825591602001919060010190611530565b5b50905061155991906116a0565b5090565b6101006040519081016040528060008152602001600081526020016000815260200160608152602001606081526020016060815260200160008152602001600081525090565b60a06040519081016040528060008152602001606081526020016060815260200160608152602001606081525090565b82805482825590600052602060002090810192821561160f579160200282015b8281111561160e5782518255916020019190600101906115f3565b5b50905061161c91906116a0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061166157805160ff191683800117855561168f565b8280016001018555821561168f579182015b8281111561168e578251825591602001919060010190611673565b5b50905061169c91906116a0565b5090565b6116c291905b808211156116be5760008160009055506001016116a6565b5090565b905600a165627a7a72305820fd9102ecd8671fdcfeda1f75687d02702c85b84ee3961ee1770f8144297a86ea0029"};

    public static final String BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {};

    public static final String SM_BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getShipemntsByCarrier\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"},{\"name\":\"_passwd\",\"type\":\"string\"}],\"name\":\"addUser\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getShipment\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_name\",\"type\":\"string\"},{\"name\":\"_info\",\"type\":\"string\"},{\"name\":\"_passwd\",\"type\":\"string\"}],\"name\":\"addCarrier\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"},{\"name\":\"_passwd\",\"type\":\"string\"}],\"name\":\"checkUser\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"getStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_user_id\",\"type\":\"uint256\"},{\"name\":\"_carrier_id\",\"type\":\"uint256\"},{\"name\":\"_from\",\"type\":\"string\"},{\"name\":\"_to\",\"type\":\"string\"}],\"name\":\"addShipment\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_shipment_id\",\"type\":\"uint256\"},{\"name\":\"_status\",\"type\":\"string\"}],\"name\":\"updateShipment\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"}],\"name\":\"gerCarrier\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_id\",\"type\":\"uint256\"},{\"name\":\"_passwd\",\"type\":\"string\"}],\"name\":\"checkCarrier\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_GETSHIPEMNTSBYCARRIER = "getShipemntsByCarrier";

    public static final String FUNC_ADDUSER = "addUser";

    public static final String FUNC_GETSHIPMENT = "getShipment";

    public static final String FUNC_ADDCARRIER = "addCarrier";

    public static final String FUNC_CHECKUSER = "checkUser";

    public static final String FUNC_GETSTATUS = "getStatus";

    public static final String FUNC_ADDSHIPMENT = "addShipment";

    public static final String FUNC_UPDATESHIPMENT = "updateShipment";

    public static final String FUNC_GERCARRIER = "gerCarrier";

    public static final String FUNC_CHECKCARRIER = "checkCarrier";

    protected Shipment(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public List getShipemntsByCarrier(BigInteger _id) throws ContractException {
        final Function function = new Function(FUNC_GETSHIPEMNTSBYCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<DynamicArray<Uint256>>() {}));
        List<Type> result = (List<Type>) executeCallWithSingleValueReturn(function, List.class);
        return convertToNative(result);
    }

    public TransactionReceipt addUser(String _name, String _passwd) {
        final Function function = new Function(
                FUNC_ADDUSER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public byte[] addUser(String _name, String _passwd, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_ADDUSER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForAddUser(String _name, String _passwd) {
        final Function function = new Function(
                FUNC_ADDUSER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple2<String, String> getAddUserInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_ADDUSER, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<String, String>(

                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue()
                );
    }

    public Tuple8<BigInteger, BigInteger, BigInteger, String, String, String, BigInteger, BigInteger> getShipment(BigInteger _id) throws ContractException {
        final Function function = new Function(FUNC_GETSHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple8<BigInteger, BigInteger, BigInteger, String, String, String, BigInteger, BigInteger>(
                (BigInteger) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue(), 
                (BigInteger) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (String) results.get(4).getValue(), 
                (String) results.get(5).getValue(), 
                (BigInteger) results.get(6).getValue(), 
                (BigInteger) results.get(7).getValue());
    }

    public TransactionReceipt addCarrier(String _name, String _info, String _passwd) {
        final Function function = new Function(
                FUNC_ADDCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_info), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public byte[] addCarrier(String _name, String _info, String _passwd, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_ADDCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_info), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForAddCarrier(String _name, String _info, String _passwd) {
        final Function function = new Function(
                FUNC_ADDCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_info), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple3<String, String, String> getAddCarrierInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_ADDCARRIER, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple3<String, String, String>(

                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue()
                );
    }

    public Boolean checkUser(BigInteger _id, String _passwd) throws ContractException {
        final Function function = new Function(FUNC_CHECKUSER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeCallWithSingleValueReturn(function, Boolean.class);
    }

    public String getStatus(BigInteger _id) throws ContractException {
        final Function function = new Function(FUNC_GETSTATUS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public TransactionReceipt addShipment(BigInteger _user_id, BigInteger _carrier_id, String _from, String _to) {
        final Function function = new Function(
                FUNC_ADDSHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_user_id), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_carrier_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_from), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_to)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public byte[] addShipment(BigInteger _user_id, BigInteger _carrier_id, String _from, String _to, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_ADDSHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_user_id), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_carrier_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_from), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_to)), 
                Collections.<TypeReference<?>>emptyList());
        return asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForAddShipment(BigInteger _user_id, BigInteger _carrier_id, String _from, String _to) {
        final Function function = new Function(
                FUNC_ADDSHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_user_id), 
                new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_carrier_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_from), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_to)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple4<BigInteger, BigInteger, String, String> getAddShipmentInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_ADDSHIPMENT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple4<BigInteger, BigInteger, String, String>(

                (BigInteger) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue()
                );
    }

    public TransactionReceipt updateShipment(BigInteger _shipment_id, String _status) {
        final Function function = new Function(
                FUNC_UPDATESHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_shipment_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_status)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public byte[] updateShipment(BigInteger _shipment_id, String _status, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_UPDATESHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_shipment_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_status)), 
                Collections.<TypeReference<?>>emptyList());
        return asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForUpdateShipment(BigInteger _shipment_id, String _status) {
        final Function function = new Function(
                FUNC_UPDATESHIPMENT, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_shipment_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_status)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple2<BigInteger, String> getUpdateShipmentInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_UPDATESHIPMENT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<BigInteger, String>(

                (BigInteger) results.get(0).getValue(), 
                (String) results.get(1).getValue()
                );
    }

    public Tuple3<BigInteger, String, String> gerCarrier(BigInteger _id) throws ContractException {
        final Function function = new Function(FUNC_GERCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple3<BigInteger, String, String>(
                (BigInteger) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue());
    }

    public Boolean checkCarrier(BigInteger _id, String _passwd) throws ContractException {
        final Function function = new Function(FUNC_CHECKCARRIER, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint256(_id), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(_passwd)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {}));
        return executeCallWithSingleValueReturn(function, Boolean.class);
    }

    public static Shipment load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new Shipment(contractAddress, client, credential);
    }

    public static Shipment deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(Shipment.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }
}
